package com.spring.common.allocation;

import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.AlibabaAliqinFcSmsNumQueryRequest;
import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
import com.taobao.api.response.AlibabaAliqinFcSmsNumQueryResponse;

/**
 * Created by anpushang on 2016/9/29.
 */
public class AliSMSExposer {

    // 阿里大鱼短信url
    private static final String serverUrl = "http://gw.api.taobao.com/router/rest";
    // 阿里大鱼短信appKey
    private static final String appKey = "23313071";
    // 阿里大鱼短信appSecret
    private static final String appSecret = "04e0020db36c4e3a6b47d0b532b258dc";

    private static AlibabaAliqinFcSmsNumSendRequest req = null;

    public static TaobaoClient client = null;

    public void initAliSMS(){
        createSendRequest();
    }
    public static AlibabaAliqinFcSmsNumSendRequest getAliSMSApi(){
        return req != null ? req : createSendRequest();
    }

    public static AlibabaAliqinFcSmsNumSendRequest createSendRequest(){
        client = new DefaultTaobaoClient(serverUrl, appKey, appSecret);
        req = new AlibabaAliqinFcSmsNumSendRequest();
        return req;
    }


    public static void main(String[] args) throws ApiException {
        TaobaoClient client = new DefaultTaobaoClient(serverUrl, appKey, appSecret);
        AlibabaAliqinFcSmsNumQueryRequest req = new AlibabaAliqinFcSmsNumQueryRequest();
//		req.setBizId("1234^1234");
        req.setRecNum("13921803505");
        req.setQueryDate("20161214");
        req.setCurrentPage(1L);
        req.setPageSize(10L);
        AlibabaAliqinFcSmsNumQueryResponse rsp = client.execute(req);
        System.out.println(rsp.getBody());
    }

}
